<?
class myacl{
	function __construct($acl,$role){
		$this->acl=$acl;
		$this->role=$role;
		}
	function allow($model,$action){
		if($this->acl->isAllowed($this->role,$model,$action)){
		echo "checked";
		}
	}
}
$acl=new myacl($this->acl,$this->role);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl?>/public/js/ben/style.css" />
<script type="text/javascript" src="<?=$this->baseUrl?>/public/js/ben/jquery.js"></script>

<title></title>
</head>
<style type="text/css">
*{margin:0;padding:0}
.main th,.main td{border:1px solid #CCC}
</style>
<body>
<form method="post" action="<?=$this->baseUrl?>/admin/control" id='control'>
<input type="hidden" name="role_id" value="<?=$this->id?>" />
<input type="hidden" name="resource[]" value="product" />
<input type="hidden" name="resource[]" value="order" />
<input type="hidden" name="resource[]" value="link" />
<input type="hidden" name="resource[]" value="admin" />
<div id='main'>
<label>权限组名:</label><input id='role' type="text" value="<?=$this->name?>" name="role" /><label>
<table class='table-1 a-left'> 
      <tr class='colhead'>
        <th>模块</th>
        <th>方法</th>
</tr>
            <tr class='f-14px even'>
        <th class='a-right'>产品 <span class="resource"><input id='product' type='checkbox'  value="product" ></span></td>
        <td id='story' class='pv-10px'>
        					  <div id='product'>                          
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='product_menumain' 
							  <?=$acl->allow("product",'menumain')?> /> 主菜单</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='product_view' 
                              <?=$acl->allow("product",'view')?> /> 查看</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='product_edit' 
                              <?=$acl->allow("product",'edit')?> /> 修改</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='product_del' 
                              <?=$acl->allow("product",'del')?> /> 删除</div>
                              </div>
                            </td>
      </tr>
            <tr class='f-14px  bg-yellow'>
        <th class='a-right'>订单<span class="resource"> <input id='order' type='checkbox'  value="order" ></span></td>
        <td id='productplan' class='pv-10px'>
        					  <div id='order'>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='order_menumain' 
                              <?=$acl->allow("order",'menumain')?> /> 主菜单</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='order_8001' 
                              <?=$acl->allow("order",'8001')?> /> 8001</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='order_8002' 
                              <?=$acl->allow("order",'8002')?> /> 8002</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='order_8003' 
                              <?=$acl->allow("order",'8003')?> /> 8003</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='order_8004' 
                              <?=$acl->allow("order",'8004')?> /> 8004</div>
							  <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='order_8005' 
                              <?=$acl->allow("order",'8005')?> /> 8005</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='order_8007' 
                              <?=$acl->allow("order",'8007')?> /> 8007</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='order_7001' 
                              <?=$acl->allow("order",'7001')?> /> 7001</div>
                              </div>
                            </td>
      </tr>
            <tr class='f-14px even'>
        <th class='a-right'>管理<span class="resource"> <input id='admin' type='checkbox'  value="admin"></span></td>
        <td id='release' class='pv-10px'>
        					   <div id='admin'>
        					  <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='admin_menumain' 
                              <?=$acl->allow("admin",'menumain')?> /> 菜单显示</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='admin_user' 
                              <?=$acl->allow("admin",'user')?> /> 用户管理</div>
                              <div class='w-p20 f-left'><input type='checkbox' name='action[]' value='admin_control' 
                              <?=$acl->allow("admin",'control')?> /> 权限管理</div>
                              </div>                          
                            </td>
      </tr>
       
              <tr class='f-14px  bg-yellow'>
        <th class='a-right'>链接管理系统<span class="resource"> <input id='link' type='checkbox'  value="link" ></span></td>
        <td id='productplan' class='pv-10px'>
        					  <div id='link'>
                       <div class='pl-5 resource'><input  type='checkbox' name='temp' value='link_menu' /> <b>管理菜单</b><br />
                              <ul class="menu_list" id='link_menu'>
                              <li><input type='checkbox' name='action[]' value='link_menuquickmenu' />快捷方式</li>
                              <li><input type='checkbox' name='action[]' value='link_menulinkadd' />添加链接</li>
                              <li><input type='checkbox' name='action[]' value='link_menuarticle'  /> 软文</li>
                              <li><input type='checkbox' name='action[]' value='link_menuclient'  /> 客户</li>
                              <li><input type='checkbox' name='action[]' value='link_menukeyword'  /> 关键字</li>
                              <li><input type='checkbox' name='action[]' value='link_menulinkmore'  /> 链接信息管理</li>
                              <li><input type='checkbox' name='action[]' value='link_menudatacheck'  /> 数据审核</li>
                              <li><input type='checkbox' name='action[]' value='link_menucheckclient'  /> 客户信息审核</li>
                              <li><input type='checkbox' name='action[]' value='link_menucheckkeyword'  /> 关键字审核</li>
                              <li><input type='checkbox' name='action[]' value='link_menuchecklink'  /> 链接信息审核</li>
                              <li><input type='checkbox' name='action[]' value='link_menusystemconfig'  /> 数据审核</li>
                              <li><input type='checkbox' name='action[]' value='link_menuindustry'  /> 行业信息管理</li>
                              <li><input type='checkbox' name='action[]' value='link_menusite'  /> 网站类型管理</li>
                              <li><input type='checkbox' name='action[]' value='link_menulinktype'  /> 链接类型管理</li>
                              <li><input type='checkbox' name='action[]' value='link_menuautocheck'  /> 自动执行设置</li>
                              </ul>
                      </div>
                       <div class='pl-5 resource'><input type='checkbox' name='temp' value='link_menuQuickLink'  /> <b>快捷方式</b><br />
                              <ul class="menu_list" id='link_menuQuickLink'>
                              <li><input type='checkbox' name='action[]' value='link_articleAdd'  /> 软文添加</li>
                              <li><input type='checkbox' name='action[]' value='link_articleDel'  /> 软文删除</li>
                              <li><input type='checkbox' name='action[]' value='link_articleEdit'  /> 软文修改</li>
                              <li><input type='checkbox' name='action[]' value='link_clientAdd'  /> 客户添加</li>
                              <li><input type='checkbox' name='action[]' value='link_clientDel'  /> 客户删除</li>
                              <li><input type='checkbox' name='action[]' value='link_clientEdit'  /> 客户修改</li>
                              <li><input type='checkbox' name='action[]' value='link_keywordAdd'  /> 关键字添加</li>
                              <li><input type='checkbox' name='action[]' value='link_keywordQuickAdd'  /> 关键字快速添加</li>
                              <li><input type='checkbox' name='action[]' value='link_keywordDel'  /> 关键字删除</li>
                              <li><input type='checkbox' name='action[]' value='link_keywordEdit'  /> 关键字修改</li>
                              </ul>
                      </div>
                       <div class='pl-5 resource'><input type='checkbox' name='temp' value='link_menuLinkMore'  /> <b>链接管理</b><br />
                              <ul class="menu_list" id='link_menuLinkMore'>
                              <li><input type='checkbox' name='action[]' value='link_linkAdd'  /> 链接添加</li>
							  <li><input type='checkbox' name='action[]' value='link_linkDel'  /> 链接删除</li>	
                              </ul>
                      </div>

                              </div>
                            </td>
      </tr>
       



            <tr>
        <th class='rowhead'>全选<input type='checkbox' id='checkAll'></th>
        <td class='a-center'> <input type='submit' id='submit' value='保存' class='button-s' name="submit" />  <input type='button' value='返回' class='button-c'  onclick="parent.Ext.getCmp('win_show').close()" /> </td>
      </tr>
    </table>

</div>
</form>
<script type="text/javascript">
$(document).ready(function(){
						$("#main input[type='checkbox']").each(function(){
																		 //$(this).attr('checked',true);
																		   });
						
						$('.resource input[type="checkbox"]').each(function(){
           				var resOur = $(this).val();						
						$('#'+resOur + ' input[type="checkbox"]').click(function(){
																				 //alert($(this).attr('checked'));
																				 if($(this).attr('checked')){
																					 $("#"+resOur).attr("checked",true);
																					 }
																				 });															
						});
						$("#control").submit(function(){
													  if($("#role").val()==""){
														  alert("权限组名称不能为空");
														  return false;
														  }
													  });
    					$(".resource input[type='checkbox']").click(function(){	
						var resOur = $(this).val();
						var check=($(this).attr('checked'))?true:false;
        				$('#'+ resOur + ' input[type="checkbox"]').each(function(){ 						
                		$('#'+resOur + ' input[type="checkbox"]').attr('checked',check);            		
        });
    });
						$("#checkAll").click(function(){
													  if($(this).attr('checked')) {
													 $("#main input[type='checkbox']").each(function(){
																		   $(this).attr('checked',true);
																		   });
													  }
													  else{
														$("#main input[type='checkbox']").each(function(){
																		   $(this).attr('checked',false);
																		   });  
													  }
													  });

						   });
</script>
</body>
</html>
